package com.ruoyi.service.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.service.domain.ServiceCategoryitems;
import com.ruoyi.service.service.IServiceCategoryitemsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 分类与项目对照表Controller
 * 
 * @author ZDL
 * @date 2024-10-21
 */
@RestController
@RequestMapping("/service/categoryitems")
public class ServiceCategoryitemsController extends BaseController
{
    @Autowired
    private IServiceCategoryitemsService serviceCategoryitemsService;

    /**
     * 查询分类与项目对照表列表
     */
    @PreAuthorize("@ss.hasPermi('service:categoryitems:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServiceCategoryitems serviceCategoryitems)
    {
        startPage();
        List<ServiceCategoryitems> list = serviceCategoryitemsService.selectServiceCategoryitemsList(serviceCategoryitems);
        return getDataTable(list);
    }

    /**
     * 导出分类与项目对照表列表
     */
    @PreAuthorize("@ss.hasPermi('service:categoryitems:export')")
    @Log(title = "分类与项目对照表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServiceCategoryitems serviceCategoryitems)
    {
        List<ServiceCategoryitems> list = serviceCategoryitemsService.selectServiceCategoryitemsList(serviceCategoryitems);
        ExcelUtil<ServiceCategoryitems> util = new ExcelUtil<ServiceCategoryitems>(ServiceCategoryitems.class);
        util.exportExcel(response, list, "分类与项目对照表数据");
    }

    /**
     * 获取分类与项目对照表详细信息
     */
    @PreAuthorize("@ss.hasPermi('service:categoryitems:query')")
    @GetMapping(value = "/{categoryitemsId}")
    public AjaxResult getInfo(@PathVariable("categoryitemsId") Long categoryitemsId)
    {
        return success(serviceCategoryitemsService.selectServiceCategoryitemsByCategoryitemsId(categoryitemsId));
    }

    /**
     * 新增分类与项目对照表
     */
    @PreAuthorize("@ss.hasPermi('service:categoryitems:add')")
    @Log(title = "分类与项目对照表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServiceCategoryitems serviceCategoryitems)
    {
        return toAjax(serviceCategoryitemsService.insertServiceCategoryitems(serviceCategoryitems));
    }

    /**
     * 修改分类与项目对照表
     */
    @PreAuthorize("@ss.hasPermi('service:categoryitems:edit')")
    @Log(title = "分类与项目对照表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServiceCategoryitems serviceCategoryitems)
    {
        return toAjax(serviceCategoryitemsService.updateServiceCategoryitems(serviceCategoryitems));
    }

    /**
     * 删除分类与项目对照表
     */
    @PreAuthorize("@ss.hasPermi('service:categoryitems:remove')")
    @Log(title = "分类与项目对照表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{categoryitemsIds}")
    public AjaxResult remove(@PathVariable Long[] categoryitemsIds)
    {
        return toAjax(serviceCategoryitemsService.deleteServiceCategoryitemsByCategoryitemsIds(categoryitemsIds));
    }
}
